<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>模块化系统架构设计</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .module-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.18);
        }
        .module-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        }
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            overflow-x: auto;
        }
        .code-block pre {
            margin: 0;
            padding: 1rem;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 0.875rem;
            line-height: 1.5;
        }
        .keyword { color: #569cd6; }
        .string { color: #ce9178; }
        .comment { color: #6a9955; }
        .function { color: #dcdcaa; }
        .number-badge {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            width: 2.5rem;
            height: 2.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            font-weight: bold;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        }
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #667eea, transparent);
            margin: 3rem 0;
        }
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        .fade-in-up {
            animation: fadeInUp 0.6s ease-out;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 text-center">
            <h1 class="text-5xl font-bold mb-4 fade-in-up">模块化系统架构设计</h1>
            <p class="text-xl mb-8 opacity-90 fade-in-up" style="animation-delay: 0.2s">
                探索现代软件系统中的模块化设计理念与实践
            </p>
            <div class="flex justify-center space-x-8 fade-in-up" style="animation-delay: 0.4s">
                <div class="text-center">
                    <i class="fas fa-cubes text-4xl mb-2"></i>
                    <p class="text-sm">10个核心模块</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-network-wired text-4xl mb-2"></i>
                    <p class="text-sm">高度解耦</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-rocket text-4xl mb-2"></i>
                    <p class="text-sm">可扩展架构</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="container mx-auto px-6 py-12">
        <div class="max-w-4xl mx-auto">
            <div class="bg-white rounded-lg shadow-lg p-8 mb-8">
                <p class="text-lg leading-relaxed text-gray-700">
                    在一个复杂的项目中，通常会有多个模块，各模块之间通过不同的机制进行调用和协作。
                    这种模块化的设计不仅提高了代码的可维护性和可扩展性，还使得团队协作更加高效。
                    让我们深入了解一个典型的电商系统中各个模块的功能和交互方式。
                </p>
            </div>
        </div>
    </section>

    <!-- System Architecture Diagram -->
    <section class="container mx-auto px-6 py-8">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold text-center mb-8 text-gray-800">系统架构概览</h2>
            <div class="bg-white rounded-lg shadow-lg p-8">
                <div class="mermaid">
                    graph TB
                        A[用户管理模块] --> B[订单管理模块]
                        B --> C[库存管理模块]
                        B --> D[支付模块]
                        B --> E[通知模块]
                        C --> F[产品管理模块]
                        A --> G[安全模块]
                        B --> G
                        H[日志监控模块] --> A
                        H --> B
                        H --> C
                        H --> D
                        I[报告模块] --> B
                        I --> A
                        I --> C
                        J[缓存模块] --> F
                        J --> A
                        style A fill:#667eea,stroke:#333,stroke-width:2px,color:#fff
                        style B fill:#764ba2,stroke:#333,stroke-width:2px,color:#fff
                        style G fill:#f093fb,stroke:#333,stroke-width:2px,color:#fff
                </div>
            </div>
        </div>
    </section>

    <div class="section-divider"></div>

    <!-- Modules Grid -->
    <section class="container mx-auto px-6 py-12">
        <div class="grid grid-cols-1 lg:grid-cols-2 gap-8 max-w-6xl mx-auto">
            
            <!-- 用户管理模块 -->
            <div class="module-card rounded-lg shadow-lg p-6">
                <div class="flex items-start mb-4">
                    <div class="number-badge mr-4">1</div>
                    <div class="flex-1">
                        <h3 class="text-2xl font-bold text-gray-800 mb-2">用户管理模块</h3>
                        <div class="flex items-center text-sm text-gray-600 mb-4">
                            <i class="fas fa-users mr-2"></i>
                            <span>User Management</span>
                        </div>
                    </div>
                </div>
                
                <div class="mb-6">
                    <h4 class="font-semibold text-gray-700 mb-2">
                        <i class="fas fa-cogs mr-2 text-purple-600"></i>功能
                    </h4>
                    <p class="text-gray-600 ml-6">处理用户注册、登录、权限管理、账户设置等。</p>
                </div>

                <div class="mb-6">
                    <h4 class="font-semibold text-gray-700 mb-2">
                        <i class="fas fa-exchange-alt mr-2 text-purple-600"></i>调用方式
                    </h4>
                    <ul class="space-y-2 ml-6">
                        <li class="text-gray-600">
                            <span class="font-medium">内部调用：</span>通过RESTful API或RPC调用其他模块，如订单管理模块进行用户身份验证。
                        </li>
                        <li class="text-gray-600">
                            <span class="font-medium">外部调用：</span>提供登录和注册API供外部系统或前端调用。
                        </li>
                    </ul>
                </div>

                <div class="code-block">
                    <pre><code><span class="comment">// 用户管理模块的API调用示例</span>
<span class="keyword">public</span> <span class="keyword">User</span> <span class="function">getUserById</span>(<span class="keyword">Long</span> userId) {
    <span class="keyword">return</span> userRepository.findById(userId).orElse(<span class="keyword">null</span>);
}</code></pre>
                </div>
            </div>

            <!-- 订单管理模块 -->
            <div class="module-card rounded-lg shadow-lg p-6">
                <div class="flex items-start mb-4">
                    <div class="number-badge mr-4">2</div>
                    <div class="flex-1">
                        <h3 class="text-2xl font-bold text-gray-800 mb-2">订单管理模块</h3>
                        <div class="flex items-center text-sm text-gray-600 mb-4">
                            <i class="fas fa-shopping-cart mr-2"></i>
                            <span>Order Management</span>
                        </div>
                    </div>
                </div>
                
                <div class="mb-6">
                    <h4 class="font-semibold text-gray-700 mb-2">
                        <i class="fas fa-cogs mr-2 text-purple-600"></i>功能
                    </h4>
                    <p class="text-gray-600 ml-6">负责订单创建、更新、查询、取消等操作。</p>
                </div>

                <div class="mb-6">
                    <h4 class="font-semibold text-gray-700 mb-2">
                        <i class="fas fa-exchange-alt mr-2 text-purple-600"></i>调用方式
                    </h4>
                    <ul class="space-y-2 ml-6">
                        <li class="text-gray-600">
                            <span class="font-medium">内部调用：</span>调用库存管理模块检查库存，调用支付模块处理支付。
                        </li>
                        <li class="text-gray-600">
                            <span class="font-medium">外部调用：</span>通过API网关暴露订单创建和查询的API。
                        </li>
                    </ul>
                </div>

                <div class="code-block">
                    <pre><code><span class="comment">// 订单管理模块调用库存管理模块</span>
<span class="keyword">public void</span> <span class="function">createOrder</span>(<span class="keyword">OrderRequest</span> request) {
    <span class="keyword">if</span> (!inventoryService.checkStock(request.getProductId(), request.getQuantity())) {
        <span class="keyword">throw new</span> InsufficientStockException();
    }
    <span class="keyword">Order</span> order = orderRepository.save(<span class="keyword">new</span> Order(request));
    paymentService.processPayment(order);
}</code></pre>
                </div>
            </div>

            <!-- 库存管理模块 -->
            <div class="module-card rounded-lg shadow-lg p-6">
                <div class="flex items-start mb-4">
                    <div class="number-badge mr-4">3</div>
                    <div class="flex-1">
                        <h3 class="text-2xl font-bold text-gray-800 mb-2">库存管理模块</h3>
                        <div class="flex items-center text-sm text-gray-600 mb-4">
                            <i class="fas fa-warehouse mr-2"></i>
                            <span>Inventory Management</span>
                        </div>
                    </div>
                </div>
                
                <div class="mb-6">
                    <h4 class="font-semibold text-gray-700 mb-2">
                        <i class="fas fa-cogs mr-2 text-purple-600"></i>功能
                    </h4>
                    <p class="text-gray-600 ml-6">管理商品库存，包括库存查询、更新和预警。</p>
                </div>

                <div class="mb-6">
                    <h4 class="font-semibold text-gray-700 mb-2">
                        <i class="fas fa-exchange-alt mr-2 text-purple-600"></i>调用方式
                    </h4>
                    <ul class="space-y-2 ml-6">
                        <li class="text-gray-600">
                            <span class="font-medium">内部调用：</span>与订单管理模块协作，进行库存检查和扣减。
                        </li>
                        <li class="text-gray-600">
                            <span class="font-medium">外部调用：</span>提供库存查询接口，供其他模块或外部系统调用。
                        </li>
                    </ul>
                </div>

                <div class="code-block">
                    <pre><code><span class="comment">// 库存管理模块检查库存</span>
<span class="keyword">public boolean</span> <span class="function">checkStock</span>(<span class="keyword">Long</span> productId, <span class="keyword">Integer</span> quantity) {
    <span class="keyword">Integer</span> stock = inventoryRepository.getStock(productId);
    <span class="keyword">return</span> stock >= quantity;
}</code></pre>
                </div>
            </div>

            <!-- 支付模块 -->
            <div class="module-card rounded-lg shadow-lg p-6">
                <div class="